#无参函数
test1 <- function()
{
  v <- sample(20:50,3,replace = T);
  a = max(v);
  cat("max: ",a,"\n")
  b = min(v);
  cat("min: ",b,"\n")
  return(mean(c(a,b)));
}


for(i in c(1:5)){
  #无参调用
  cat("3n-max-min-mean:",test1(),"\n")
}

cat("-----------------------------------\n");

#带参函数

test2 <- function(jh)
{
  v <- sample(jh,replace = T);
  a = max(v);
  cat("max: ",a,"\n")
  b = min(v);
  cat("min: ",b,"\n")
  return(mean(c(a,b)));
}

jh <- c(20:50)
for(i in c(1:5)){
  #带参数调用
  cat("3n-max-min-mean:",test2(jh),"\n")
}


roll <- function(){
  dice_faces <- 1:6
  probabilities <- c(1/8, 1/8, 1/8, 1/8, 1/8, 3/8)
  result <- sample(dice_faces, size = 2, prob = probabilities)
  return (sum(result))
}

qplot(replicate(100000,roll()),binwidth =1 )
